<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport"
		content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>粉丝消息</title>
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<style>
		#app .header {
			height: 44px;
			background-color: #ffffff;
			font-size: 16px;
			padding: 0 15px;
			position: fixed;
			top: 0;
			right: 0;
			left: 0;
			display: flex;
			align-items: center;
			justify-content: space-between;
		}

		#app .header img {
			width: 22px;
			height: 22px;
		}


		#app .content {
			width: 100%;
			padding: 15px 15px 10px;
			box-sizing: border-box;
		}

		#app .content .content_box {
			width: 100%;
			border-radius: 10px;
			background-color: #ffffff;
			margin-bottom: 15px;
		}

		#app .content .content_box .box_top {
			width: 100%;
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			justify-content: space-between;
			font-size: 16px;
			color: #999;
			padding: 12px 15px;
			box-sizing: border-box;
			border-bottom: 1px solid #e5e5e5;
		}

		#app .content .content_box .box_top .r_tp {
			color: #000;
			font-weight: bold;
		}

		#app .content .content_box .box_top .r_bt {
			font-size: 12px;
		}

		#app .content .content_box .box_bot {
			width: 100%;
			display: flex;
			flex-wrap: nowrap;
			padding: 15px;
			box-sizing: border-box;
		}

		#app .content .content_box .box_bot img {
			width: 55px;
			height: 55px;
			border-radius: 50%;
			margin-right: 10px;
			object-fit: fill;
		}

		#app .content .content_box .box_bot .bot_right {
			flex: 1;
			width: 100%;
			font-size: 14px;
			color: #999;
			line-height: 14px;
			display: flex;
			flex-direction: column;
			justify-content: center;
		}

		#app .content .content_box .box_bot .bot_right .b_tp {
			font-size: 16px;
			line-height: 16px;
			color: #000;
			font-weight: bold;
			margin-bottom: 10px;
		}
	</style>
</head>

<body>
	<div id="app">
		<div class="header">
			<img src="../../image/icon_return.png" alt="" onclick="back()">粉丝消息
			<img src="../../image/icon_refresh.png" alt="" onclick="refresh_list()">
		</div>
		<div class="content">

		</div>
	</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript">
	var next_p = 1;
	apiready = function () {
		resume("message_fans");

		$api.dom('.content').style.paddingTop = $api.fixStatusBar($api.dom('.header')) + 15 + 'px';
		addEvent();
		message();
	}

	function addEvent() {
		api.addEventListener({
			name: 'scrolltobottom',
			extra: {
				threshold: 1000,
			},
		}, function (ret, err) {
			message();
			api.removeEventListener({
				name: 'scrolltobottom'
			});
			setTimeout(function () {
				addEvent()
			}, 1000)
		});
	}

	function message() {
		$api.ajax({
			url: 'api/message/list',
			method: 'get',
			data: {
				values: {
					next_p: next_p,
					type: 2
				}
			},
			page: next_p,
			timeOutHtml: $api.dom(".content")
		}, function (ret) {
			next_p = ret.data.next_p;
			ret.data.list.forEach(item => {
				let html = `<div class="content_box">
				<div class="box_top">
					<div class="r_tp">新增粉丝</div>
					<div class="r_bt">`+ getLocalTime(item.create_time) + `</div>
				</div>
				<div class="box_bot">
					<img src="` + item.pic_url + `" alt="">
					<div class="bot_right">
						<div class="b_tp">`+ item.comment + `</div>
						<div class="b_bt">`+ item.content + `</div>
					</div>
				</div>
			</div>`
				$api.append($api.dom(".content"), html)
			});
		});
	}
	function refresh_list() {
		next_p = 1;
		$api.html($api.dom(".content"), "");
		message();
	}
	function back() {
		api.closeWin({
		});
	}
</script>

</html>